<template>
<div>
    <el-container>
    <el-header>
        <div class="head" style="height:60px">
            <b>健康信息反馈</b>
        </div>
    </el-header>
    </el-container>
    <div class="advice">
        &nbsp&nbsp&nbsp&nbsp<b>检测信息：</b><br><br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您的舒张压为：{{this.userData.bloodPressureE}}mmHg<br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您的收缩压为：{{this.userData.bloodPressureS}}mmHg<br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您的体温为：{{this.userData.temperature}}℃<br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您的心率为：{{this.userData.ecg}}次/分钟<br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您的血氧为：{{this.userData.bloodOxygen}}%
    </div>
    <div class="advice">
        &nbsp&nbsp&nbsp&nbsp<b>健康建议：</b><br><br>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{{this.advice}}
    </div>
</div>
</template>
<script>
import { post, get } from "../ajax";
export default {
    name:"Sign",
    data(){
        return{
            userData:"",
            advice:"",
            userId:1
        };
    },
    created(){
        this.userId = parseInt(this.$route.query.userId);
        this.getdata();
        this.getadvice();
    },
    methods:{
        async getdata(){
            const res = await get("/SmartMachine/api/Sign/datas" , {
                body: {
                    userId: this.userId
                }
            });
            if(!res.error){
                this.userData = res.data;
                console.log(this.userData);
            }
        },
        async getadvice(){
            const sleep = ms =>new Promise(resolve => setTimeout(resolve,ms));
            await sleep(2000);
            const data ={
                bloodOxygen:this.userData.bloodOxygen,
                bloodPressureE:this.userData.bloodPressureE,
                bloodPressureS:this.userData.bloodPressureS,
                temperature:this.userData.temperature,
                ECG:this.userData.eCG
            };
            
            const res = await post("/SmartMachine/api/Sign/info" , {
                body: data,
            });
            if(!res.error){
                
                this.advice = res.data;
                console.log(this.advice);
            }
        } 
    }
    
}
</script>

<style scoped>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 90px;
}
.head{
    height: 60px;
    font-size: 30px;
    font-weight: 300;
}
.advice{
    margin-top: 50px;
    margin-left: 30px;
    font-size: 25px;
    font-weight: 100;
  text-align:left!important;
}
</style> 